﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Concurrent;

namespace Base.DAL
{
    /// <summary>
    /// 数据解析接口
    /// 规定数据如何转换、存储
    /// </summary>
    public interface IDataParser
    {
        /// <summary>
        /// 从字符串中解析数据，并更新最新数据缓存
        /// </summary>
        /// <param name="cqbh">测区编号</param>
        /// <param name="data">数据内容</param>   
        /// <param name="dt">解析时刻</param>
        /// <param name="cache">当前最新数据缓存</param>
        /// <returns>转换后的数据，转换失败为null</returns>
        object Parse(int cqbh, string data, DateTime dt, IEnumerable<IEntity> cache);
        /// <summary>
        /// 获取正则验证字符串
        /// </summary>
        /// <returns>正则验证字符串</returns>
        string RegexPattern();
        /// <summary>
        /// 存储数据
        /// </summary>
        /// <param name="data">待存储的数据</param>
        void Storage(ConcurrentQueue<IEntity> data);

        /// <summary>
        /// 存储当前数据
        /// </summary>
        /// <param name="cqbh">测区编号</param>
        /// <param name="data">待存储的数据</param>
        void StorageCur(IEnumerable<IEntity> data);


        /// <summary>
        /// 获取最新一条数据时间
        /// </summary>
        /// <param name="cqbh">测区编号</param>
        /// <param name="hSpan">加权时长</param>
        /// <returns></returns>
        //DateTime LastDateTime(int cqbh, int hSpan);

        /// <summary>
        /// 数据计算，进行加权平均操作
        /// </summary>
        /// <param name="tStart">计算起始时刻</param>
        /// <param name="tEnd">计算结束时刻</param>
        /// <param name="hSpan">加权平均时长，取2，4，8，12，24</param>
        void Calc(DateTime tStart,DateTime tEnd,int hSpan);
    }
}
